import { useRedis } from '@sker/core'
import { RedisClientType } from 'redis'
class VipDeviceList {
    constructor(private r: RedisClientType, private uuid: string) { }
    /**
     * 
     * @param userId 
     * @param openTime 
     */
    async addWait(userId: string, openTime: number) {
        await this.r.zAdd(`vip.wait.${this.uuid}`, {
            score: openTime,
            value: userId
        })
    }
    /**
     * 参加活动
     * @param userId 直播间 用户id
     * @param openTime 开奖时间
     */
    async joinRoom(userId: string, openTime: number) {
        this.r.zAdd(`vip.list.${this.uuid}`, {
            score: openTime,
            value: userId
        })
    }
    /**
     * 
     * @param userId 直播间
     * @param count 
     */
    async setResult(userId: string, count: number) {
        this.r.zAdd(`vip.result.${this.uuid}`, {
            score: count,
            value: JSON.stringify({ userId, time: new Date().getTime() })
        })
    }
}

export default async () => {
    const uuid = ``
    useRedis(4, async (r) => {
        const vip = new VipDeviceList(r, uuid)
    })
}